use "rawdata.dta", clear

**data setup

**treatment assignment
gen treatment = 0
replace treatment = 1 if check_t1 != .
replace treatment = 2 if check_t2 != .
replace treatment = 3 if check_t3 != .

lab define treatment 0 "Control" 1 "Cheerleading" 2 "New normal" 3 "US coercion"
lab value treatment treatment


** merging the three different question wordings of blame
recode blame* (. = 0)
gen blame_employer = blame1_1 + blame2_1 + blame3_1
gen blame_foreign = blame1_2 + blame2_2 + blame3_2
gen blame_globalization = blame1_3 + blame2_3 + blame3_3
gen blame_covid = blame1_4 + blame2_4 + blame3_4
gen blame_self = blame1_5 + blame2_5 + blame3_5
gen blame_govt = blame1_6 + blame2_6 + blame3_6
gen blame_other = blame1_7 + blame2_7 + blame3_7

label var blame_employer "Employer"
label var blame_foreign "Foreign government"
label var blame_globalization "Globalization"
label var blame_covid "Covid-19"
label var blame_self "Self"
label var blame_govt "Local government"
label var blame_other "Other"

** dropping "don't knows"
drop if blame_employer == 0
drop if blame_foreign == 0
drop if blame_globalization == 0
drop if blame_covid == 0
drop if blame_self == 0
drop if blame_govt == 0
drop if blame_other == 0

** blame assignment rankings
*ssc install rowranks: higher numbers = ranked higher (more blame)
rowranks blame_employer blame_foreign blame_globalization blame_covid blame_self blame_govt blame_other, gen(r1-r7)

label var r1 "Employer"
label var r2 "Foreign government"
label var r3 "Globalization"
label var r4 "Covid-19"
label var r5 "Self"
label var r6 "Local government"
label var r7 "Other"


**demographics
gen male = 2 - gender
gen age = 2023 - year
gen han = 2 - ethnicity
gen urban = hukou - 1
gen ccp = 0 
replace ccp = 1 if politicalstatus == 1
recode income (8 9 = .)
gen manu = 0
replace manu = 1 if industry == 2
gen private = 0 
replace private = 1 if work_type == 10
gen soe = 0
replace soe = 1 if inlist(work_type, 2, 3, 6, 9)
tab region, gen(region)
gen nationalism = 6- (nationalism_1 + nationalism_2 + nationalism_3 + nationalism_4 + nationalism_5) /5

** info source

recode infosource_1-infosource_6 (. = 0)
label var infosource_1 "Domestic print media"
label var infosource_2 "Domestic TV"
label var infosource_3 "Domestic social media"
label var infosource_4 "Foreign print media"
label var infosource_5 "Foreign TV"
label var infosource_6 "Foreign social media"
*statplot infosource_1-infosource_6, ytitle(News source)


**hardship
gen hardship_self2 = 2 - hardship_self
gen hardship_others2 = 1
replace hardship_others2 = 0 if hardship_others == 4 

gen hardship = 1
replace hardship = 0 if hardship_self2 == 0 & hardship_others2 == 0

**comprehension check

gen pass1 = 0
replace pass1 = 1 if check_control == 2 & check2_control == .
replace pass1 = 1 if check_t1 == 2 & check2_t1 == .
replace pass1 = 1 if check_t2 == 3 & check2_t2 == .
replace pass1 = 1 if check_t3 == 4 & check2_t3 == .

gen pass2 = 0
replace pass2 = 1 if check2_control == 2 
replace pass2 = 1 if check2_t1 == 2 
replace pass2 = 1 if check2_t2 == 3 
replace pass2 = 1 if check2_t3 == 4 

gen pass = pass1 + pass2


**ANALYSIS

*drop speeders

keep if duration >= 180


** Table 1 summary stats for DV

**Note: you need STATA 18 for the command dtable to work
preserve
keep if pass == 1
dtable r1-r7, by(treatment) nformat(%7.2f mean sd) export(table1.html, replace)
restore

**Figure 1 and Appendix Table A3

**ATE: ranking
preserve
keep if pass == 1
reg r1 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA3, excel replace
est store a
reg r2 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA3, excel append
est store b
reg r3 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA3, excel append
est store c
reg r4 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA3, excel append
est store d
reg r5 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA3, excel append
est store e
reg r6 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA3, excel append
est store f
reg r7 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA3, excel append
est store g
coefplot a, bylabel(Employer) || b, bylabel(Foreign) || c, bylabel(Globalization) || ///
		 d, bylabel(Covid) || e, bylabel(Self) || f, bylabel(Local) || g, bylabel(Other) ||, ///
		 keep (1.treatment 2.treatment 3.treatment) byopts(compact rows(1)) xline(0) xtitle(Blame rankings)
*graph save "figure1", replace
restore


**Open ended responses: Figure 3 and Appendix Table A4

preserve
keep if pass == 1
reg othergovt i.treatment hardship  male age urban ccp education income manu private soe, robust
outreg2 using tableA4, excel replace
coefplot, keep (1.treatment 2.treatment 3.treatment) xline(0) xtitle(Blame government) scale(2)
graph save "figure3", replace
restore

**APPENDIX

// Appendix 1: Balance check

dtable hardship male age urban ccp education income manu private soe, by(treatment) nformat(%7.2f mean) export(tableA1.html, replace)
anova hardship treatment
anova male treatment
anova age treatment
anova urban treatment
anova ccp treatment
anova education treatment
anova income treatment
anova manu treatment
anova private treatment
anova soe treatment


// Appendix 2: predicting passing manipulation check
preserve
logit pass hardship male age urban ccp education income manu private soe if duration >=180, robust
outreg2 using tableA2, excel replace
restore


// Appendix 4: Treatment heterogeneity

gen nationalism2 = 0
replace nationalism2 = 1 if nationalism == 5

**nationalism
preserve
keep if pass == 1
reg r1 i.treatment##i.nationalism2 hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA5, excel replace
est store a
reg r2 i.treatment##i.nationalism2 hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA5, excel append
est store b
reg r3 i.treatment##i.nationalism2 hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA5, excel append
est store c
reg r4 i.treatment##i.nationalism2 hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA5, excel append
est store d
reg r5 i.treatment##i.nationalism2 hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA5, excel append
est store e
reg r6 i.treatment##i.nationalism2 hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA5, excel append
est store f
reg r7 i.treatment##i.nationalism2 hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA5, excel append
est store g

restore

**foreign media
gen foreignnews = infosource_4 + infosource_5 + infosource_6
recode foreignnews (2 3 = 1)

preserve
keep if pass == 1
reg r1 i.treatment##i.foreignnews hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA6, excel replace
est store a
reg r2 i.treatment##i.foreignnews hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA6, excel append
est store b
reg r3 i.treatment##i.foreignnews hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA6, excel append
est store c
reg r4 i.treatment##i.foreignnews hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA6, excel append
est store d
reg r5 i.treatment##i.foreignnews hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA6, excel append
est store e
reg r6 i.treatment##i.foreignnews hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA6, excel append
est store f
reg r7 i.treatment##i.foreignnews hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA6, excel append
est store g

restore

**education
preserve
keep if pass == 1
reg r1 i.treatment##c.education hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA7, excel replace
reg r2 i.treatment##c.education hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA7, excel append
reg r3 i.treatment##c.education hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA7, excel append
reg r4 i.treatment##c.education hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA7, excel append
reg r5 i.treatment##c.education hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA7, excel append
reg r6 i.treatment##c.education hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA7, excel append
reg r7 i.treatment##c.education hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA7, excel append
restore

**additional HTEs:

**hardship
preserve
keep if pass == 1
reg r1 i.treatment##i.hardship hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##i.hardship hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##i.hardship hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##i.hardship hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##i.hardship hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##i.hardship hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##i.hardship hardship male age urban ccp education income manu private soe, robust
restore

**gender
preserve
keep if pass == 1
reg r1 i.treatment##i.male hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##i.male hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##i.male hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##i.male hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##i.male hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##i.male hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##i.male hardship male age urban ccp education income manu private soe, robust
restore

**age
preserve
keep if pass == 1
reg r1 i.treatment##c.age hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##c.age hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##c.age hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##c.age hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##c.age hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##c.age hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##c.age hardship male age urban ccp education income manu private soe, robust
restore

**urban
preserve
keep if pass == 1
reg r1 i.treatment##i.urban hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##i.urban hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##i.urban hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##i.urban hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##i.urban hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##i.urban hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##i.urban hardship male age urban ccp education income manu private soe, robust
restore

**ccp
preserve
keep if pass == 1
reg r1 i.treatment##i.ccp hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##i.ccp hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##i.ccp hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##i.ccp hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##i.ccp hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##i.ccp hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##i.ccp hardship male age urban ccp education income manu private soe, robust
restore

**income
preserve
keep if pass == 1
reg r1 i.treatment##c.income hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##c.income hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##c.income hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##c.income hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##c.income hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##c.income hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##c.income hardship male age urban ccp education income manu private soe, robust
restore

**manu
preserve
keep if pass == 1
reg r1 i.treatment##i.manu hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##i.manu hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##i.manu hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##i.manu hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##i.manu hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##i.manu hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##i.manu hardship male age urban ccp education income manu private soe, robust
restore

**private
preserve
keep if pass == 1
reg r1 i.treatment##i.private hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##i.private hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##i.private hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##i.private hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##i.private hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##i.private hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##i.private hardship male age urban ccp education income manu private soe, robust
restore

**soe
preserve
keep if pass == 1
reg r1 i.treatment##i.soe hardship male age urban ccp education income manu private soe, robust
reg r2 i.treatment##i.soe hardship male age urban ccp education income manu private soe, robust
reg r3 i.treatment##i.soe hardship male age urban ccp education income manu private soe, robust
reg r4 i.treatment##i.soe hardship male age urban ccp education income manu private soe, robust
reg r5 i.treatment##i.soe hardship male age urban ccp education income manu private soe, robust
reg r6 i.treatment##i.soe hardship male age urban ccp education income manu private soe, robust
reg r7 i.treatment##i.soe hardship male age urban ccp education income manu private soe, robust
restore


// Appendix 5: Main results including those who fail the comprehension check


**ranking
reg r1 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA8, excel replace
reg r2 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA8, excel append
reg r3 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA8, excel append
reg r4 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA8, excel append
reg r5 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA9, excel append
reg r6 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA8, excel append
reg r7 i.treatment hardship male age urban ccp education income manu private soe, robust
outreg2 using tableA8, excel append
